class solution:
    def rotate(self, nums: list[int], k: int) -> None:
        n = len(nums)
        k = k % n
        self.reverse(nums, 0, n-1)
        self.reverse(nums, 0, k-1)
        self.reverse(nums, k, n-1)
        print(nums)

    def reverse(self, nums:list[int], left: int, right:int) ->None:         #
        while left < right:
            tmp = nums[left]
            nums[left] = nums[right]
            nums[right] = tmp
            left += 1
            right -= 1


sol = solution()

nums =[1,2,3,4,5,6,7]
k = 3

sol.rotate(nums, k)